<template>
	<view class="cases-list">
		<view v-if="patientNeesInfo" class="person flex-row-start">
			<view class="photo bg-cover" :style="{backgroundImage: 'url(https://cdn.yingpaipay.com/' + (patientNeesInfo.patientSex == '0' ? 'man.png' : 'woman.png') + ')'}"></view>
			<view class="info flex-1">
				<view class="p1">
					<text class="t1">{{patientNeesInfo.patientName}}</text>
					<text class="t2">{{patientNeesInfo.patientSex == '0' ? '男' : '女'}}</text>
					<text>{{patientNeesInfo.patientAge}}岁</text>
				</view>
				<view class="p2">就诊卡：{{patientNeesInfo.outpatientNumber}}</view>
			</view>
		</view>
		<!-- 列表 -->
		<view :style="{height: 'calc(100vh - 184rpx)'}">
			<z-paging
				ref="paging"
				:auto="false"
				:fixed="false"
				v-model="dataList"
				@query="queryList"
				show-refresher-when-reload
				show-refresher-update-time
			>
				<view v-for="(item, index) in dataList" :key="index" class="cases-items" @click.stop="gotoRouter('/pages-doctor/cases/detail?id=' + item.id)">
					<view class="v1 flex-row-between">
						<view class="flex-1 flex-row-start">
							<view class="t1">[专家]</view>
							<view class="p bg-cover" :style="{backgroundImage: 'url(' + item.doctorPicture + ')'}"></view>
							<view class="t2">{{item.doctorName}}</view>
							<view class="t3">{{item.departmentName}}</view>
						</view>
						<view class="t4">{{item.visitTime.substring(0, 10)}}</view>
					</view>
					<view class="v2">诊断：<text class="t5">{{item.diseasesName}}</text></view>
				</view>
			</z-paging>
		</view>
	</view>
</template>

<script>
	import zPaging from '../components/z-paging/components/z-paging/z-paging.vue';
	export default {
		components: {
			zPaging
		},
		data() {
			return {
				patientNeesInfo: null,
				dataList: [],
			}
		},
		onLoad(options) {
			this.patientNeesInfo = JSON.parse(options.params)
		},
		onShow() {
			this.$nextTick(() => {
				if (this.$refs.paging) {
					this.$refs.paging.reload();
				}
			});
		},
		methods: {
			// 获取列表数据
			queryList(pageNo, pageSize) {
				const params = {
					pageNo: pageNo,
					pageSize: pageSize,
					patientId: this.patientNeesInfo.patientId
				};
				this.$api.getCasesList(params).then((res) => {
					if (res.success) {
						this.$refs.paging.complete(res.result ? res.result.records : []);
					} else {
						this.$refs.paging.complete(false);
					}
				}).catch((res) => {
					this.$refs.paging.complete(false);
				});
			},
		}
	}
</script>

<style lang="less" scoped>
@import './list.less';
</style>
